﻿using UnityEngine;
using System.Collections;

public class CameraDrugBehavior : MonoBehaviour {

	public bool cameraMove = false;
	public float interval = 1f;

	private static CameraDrugBehavior instance;
	public static CameraDrugBehavior Instance { get { return instance; } }

	void Awake()
	{
		if(instance == null)
			instance = this;
	}

	// Use this for initialization
	void Start () {
	
	}
	
	// Update is called once per frame
	void Update ()
	{
		if(cameraMove)
		{
			float x = Mathf.Abs(Time.time/interval - Mathf.Floor(Time.time/interval) - 0.5f)*2;
			x = Mathf.SmoothStep(-35, 35, x);
			Vector3 rotation = new Vector3(0, x, 0);
			Camera.main.transform.rotation = Quaternion.Euler(rotation);
			Camera.main.transform.Rotate(Player.Instance.transform.rotation.eulerAngles);
		}
	}

	public void MoveCameraDir()
	{
		cameraMove = true;
		//StartCoroutine(MoveCameraDirection);
	}

	/*private IEnumerator MoveCameraDirection()
	{
		while(cameraMove)
		{
			iTween.MoveTo(GameObject.Find("Player").camera, transform.localScale*scaleChangeFactor, scaleChangeInterval);
		}
	}
	*/
}
